package sms
import (
	"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
	"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
	sms "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms/v20210111"
)

type smsSt struct {
	client *sms.Client
	appid string
	signname string
}

type smsInt interface{
	/*
		@des: 发送验证码
		@param phone_number: 手机号码
		@param tempid: 短信模板id，来自于tencent后台
		@param verifycode: 验证码
		@param expiretime: 过期时间
		@return ret_code: 返回码
		@return err: 错误信息
	*/
	SendVerifyCode(phone_number string, tempid string, verifycode string, expiretime string)(ret_code int32, err error)
}

func New(secretid string, secretkey string, appid string, signname string) (smsInt, error) {
	credential := common.NewCredential(secretid, secretkey)
	cpf := profile.NewClientProfile()
	client, err := sms.NewClient(credential, "ap-beijing", cpf)

	if err != nil {
		return nil, err
	}
	return &smsSt{client:client,
					appid:appid,
					signname:signname}, nil
}